<%@ Page AutoEventWireup="true" CodeFile="ResearchContactsManagement.aspx.cs" Inherits="PHSRAG.Insight21.Admin.ResearchContactsManagement"
    Language="C#" %>

<%@ Register Assembly="PHSRAG.WebControls" Namespace="PHSRAG.WebControls" TagPrefix="cc2" %>
<%@ Register Assembly="PHSRAG.Insight21.InsightWebControls" Namespace="PHSRAG.Insight21.InsightWebControls"
    TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Research Contacts Management</title>
    <link href="../Insight21.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
		function SelectContact(admPersonIdControlId, contactNameControlId)
		{
			var contactDetails = window.showModalDialog('AdminSearchUsers.aspx?urlReferrer=ResearchContactsManagement.aspx&showAsPopup=true&admPersonIdControlId=' 
			+ admPersonIdControlId + '&contactNameControlId=' + contactNameControlId, 'ContactPicker', 
			'', GetDialogFeatures(600, 200));
			if (contactDetails)
			{
				document.getElementById(admPersonIdControlId).value = contactDetails.split(";")[1];
				document.getElementById(contactNameControlId).innerText = contactDetails.split(";")[0];
			}
			return false;
		}
		function GetDialogFeatures(dialogWidth, dialogHeight)
		{
			return "dialogWidth: " + dialogWidth + 
					"px;dialogHeight: " + dialogHeight + 
					"px;status: yes;scroll: yes;resizable: yes;";
		}
		
        function getconfirm() 
        { 
            if (confirm("Do you want to delete record?")==true) 
            return true; 
            else 
            return false; 
        }

  
    </script>

</head>
<body>
    <form id="researchContactsManagement" runat="server">
        <div>
            <table cellpadding="0" class="Container" width="100%">
                <tr>
                    <td>
                        <table class="Header" width="100%">
                            <tr>
                                <td>
                                    <cc1:Header ID="header" runat="server" OnNavigate="OnNavigate" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <cc1:AdminSubNavigation ID="adminSubNavigation" runat="server" />
                                </td>
                            </tr>
                        </table>
                        <cc2:BreadCrumb ID="breadCrumb" runat="server" />
                        <table width="100%">
                            <tr>
                                <td>
                                    <cc2:Annunciator ID="annunciator" runat="server" />
                                </td>
                            </tr>
                        </table>
                        <table>
                            <tr>
                                <td>
                                    <asp:ValidationSummary ID="valSummary" runat="server" HeaderText="The following errors occurred:"
                                        Width="100%" />
                                </td>
                            </tr>
                        </table>
                        <cc2:PostbackGuard ID="postbackGuard" runat="server" />
                        <table width="100%">                          
                            <tr>
                                <td style="width: 85%">
                                    <table cellpadding="0" cellspacing="0" class="SearchAdmin">
                                        <tr>
                                            <td>
                                                <asp:Literal ID="ltInstitution" Text="Select Institution" runat="server"></asp:Literal>
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="ddInstitution" runat="server" CssClass="FlatDropDown" DataTextField="Text"
                                                    DataValueField="Value" AutoPostBack="true" OnSelectedIndexChanged="OnDDInstitutionSelectedIndexChanged">
                                                </asp:DropDownList>
                                            </td>
                                            <td>
                                                <asp:Literal ID="ltChiefCode" Text="Select ChiefCode" runat="server"></asp:Literal>
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="ddChiefCode" runat="server" CssClass="FlatDropDown" DataTextField="Text"
                                                    DataValueField="Value">
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:Literal ID="ltLastName" runat="server" Text="Last Name"></asp:Literal>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtLastName" MaxLength="50" runat="server"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:Literal ID="ltFirstName" runat="server" Text="First Name"></asp:Literal>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtFirstName" MaxLength="50" runat="server"></asp:TextBox>
                                                <asp:ImageButton ID="btnSearch" runat="server" OnClick="onFilter" ImageUrl="../Images/b_search.gif" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 85%">
                                    <asp:Panel ID="gridContainer" runat="server" Visible="False">
                                        <table cellspacing="0" class="DataTitle" width="85%">
                                            <tr>
                                                <td>
                                                    Research Contacts Management |
                                                    <asp:Label ID="recordCount" runat="server"></asp:Label>&nbsp;Records&nbsp;
                                                </td>
                                            </tr>
                                        </table>
                                        <table cellspacing="0" width="85%">
                                            <tr>
                                                <td>
                                                    <cc2:Pager ID="topPager" runat="server" OnFirstPage="OnFirstPage" OnLastPage="OnLastPage"
                                                        OnNextPage="OnNextPage" OnPreviousPage="OnPreviousPage" />
                                                </td>
                                            </tr>
                                        </table>
                                        <table cellspacing="0" width="85%">
                                            <tr>
                                                <td>
                                                    <asp:DataGrid ID="dgResearchContacts" runat="server" AllowCustomPaging="True" AllowPaging="True"
                                                        AllowSorting="True" AutoGenerateColumns="False" CssClass="DataGrid" OnCancelCommand="OnResearchContactsCancelCommand"
                                                        OnEditCommand="OnResearchContactsEditCommand" OnItemDataBound="OnResearchContactsItemDataBound"
                                                        OnItemCreated="OnResearchContactsItemCreated" OnUpdateCommand="OnResearchContactsUpdateCommand"
                                                        OnItemCommand="OnItemCommand" Width="100%">
                                                        <AlternatingItemStyle CssClass="DataGridAlternatingItem" />
                                                        <ItemStyle CssClass="DataGridItem" />
                                                        <HeaderStyle CssClass="DataGridHeader" />
                                                        <Columns>
                                                            <asp:TemplateColumn HeaderText="FwkDomainOrganizationId" Visible="False">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="fwkDomainOrganizationId" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "FwkDomainOrganizationId")%>'>
                                                                    </asp:Label>
                                                                </ItemTemplate>
                                                            </asp:TemplateColumn>
                                                            <asp:TemplateColumn HeaderText="Institution">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="institution" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Institution")%>'>
                                                                    </asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:DropDownList ID="institutionEdit" runat="server" CssClass="FlatDropDown" DataSource='<%#Institutions%>'
                                                                        DataTextField="Text" DataValueField="Value" AutoPostBack="true" OnSelectedIndexChanged="OnInstitutionSelectedIndexChanged">
                                                                    </asp:DropDownList><asp:RequiredFieldValidator ID="rfvInstitution" runat="server"
                                                                        ErrorMessage="Please select an Institution" ControlToValidate="institutionEdit"
                                                                        InitialValue="0">*</asp:RequiredFieldValidator>
                                                                </EditItemTemplate>
                                                            </asp:TemplateColumn>
                                                            <asp:TemplateColumn HeaderText="Chief Code">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="chiefCode" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "ChiefCode")%>'>
                                                                    </asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:DropDownList ID="chiefCodeEdit" runat="server" CssClass="FlatDropDown" DataTextField="Text"
                                                                        DataValueField="Value">
                                                                    </asp:DropDownList><asp:RequiredFieldValidator ID="rfvChiefCode" runat="server" ErrorMessage="Please select a Chief code"
                                                                        ControlToValidate="chiefCodeEdit" InitialValue="0">*</asp:RequiredFieldValidator>
                                                                </EditItemTemplate>
                                                            </asp:TemplateColumn>
                                                            <asp:TemplateColumn HeaderText="Roles">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="Roles" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Role")%>'>
                                                                    </asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:DropDownList ID="roleEdit" runat="server" CssClass="FlatDropDown" DataTextField="Text"
                                                                        DataValueField="Value" AutoPostBack="true" OnSelectedIndexChanged="OnRoleSelectedIndexChanged">
                                                                    </asp:DropDownList><asp:RequiredFieldValidator ID="rfvRole" runat="server" ErrorMessage="Please select a Role"
                                                                        ControlToValidate="roleEdit" InitialValue="0">*</asp:RequiredFieldValidator>
                                                                </EditItemTemplate>
                                                            </asp:TemplateColumn>
                                                            <asp:TemplateColumn HeaderText="Sponsor Type">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="admSponsorType" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "AdmSponsorTypeName")%>'>
                                                                    </asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:DropDownList ID="admSponsorTypeEdit" runat="server" CssClass="FlatDropDown"
                                                                        DataTextField="Text" DataValueField="Value">
                                                                    </asp:DropDownList><asp:RequiredFieldValidator ID="rfvSponsorType" runat="server"
                                                                        ErrorMessage="Please select the type of Sponsor " ControlToValidate="admSponsorTypeEdit"
                                                                        InitialValue="0">*</asp:RequiredFieldValidator>
                                                                </EditItemTemplate>
                                                            </asp:TemplateColumn>
                                                            <asp:TemplateColumn HeaderText="Contact Person">
                                                                <ItemTemplate>
                                                                    Name:
                                                                    <asp:Label ID="contactPersonName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "FullName")%>'></asp:Label><br />
                                                                    Phone:
                                                                    <asp:Label ID="contactPersonNumber" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Phone")%>'></asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <input id="admPersonId" runat="server" type="hidden" value='<%#DataBinder.Eval(Container.DataItem, "AdmPersonId")%>' />
                                                                    <asp:TextBox ID="contactPersonEdit" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "FullName")%>'
                                                                        ReadOnly="True" BackColor="#ffffff"></asp:TextBox>
                                                                    &nbsp;&nbsp;&nbsp;
                                                                    <asp:ImageButton ID="selectContact" runat="server" ImageUrl="../Images/b_selectcontact.gif" />
                                                                    <asp:RequiredFieldValidator ID="rfcContactPerson" runat="server" ErrorMessage="Please select a Contact Person"
                                                                        ControlToValidate="contactPersonEdit">*</asp:RequiredFieldValidator>
                                                                </EditItemTemplate>
                                                            </asp:TemplateColumn>
                                                            <asp:EditCommandColumn CancelText="Cancel" EditText="Edit" UpdateText="Update"></asp:EditCommandColumn>
                                                            <asp:TemplateColumn>
                                                                <ItemTemplate>
                                                                    <asp:LinkButton ID="cmdDelete" runat="server" Text="Delete" CommandName="Delete">
                                                                    </asp:LinkButton>
                                                                </ItemTemplate>
                                                            </asp:TemplateColumn>
                                                        </Columns>
                                                        <PagerStyle Visible="False" />
                                                    </asp:DataGrid></td>
                                            </tr>
                                        </table>
                                        <table cellspacing="0" width="85%">
                                            <tr>
                                                <td>
                                                    <cc2:Pager ID="bottomPager" runat="server" OnFirstPage="OnFirstPage" OnLastPage="OnLastPage"
                                                        OnNextPage="OnNextPage" OnPreviousPage="OnPreviousPage" />
                                                </td>
                                            </tr>
                                        </table>
                                    </asp:Panel>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:ImageButton ID="add" runat="server" OnClick="OnAddRow" ImageUrl="../Images/b_add_new.gif" />
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
